
#include <iostream>
#include "CompileToRun.hpp"
#include "../HttpServer/HttpServer.hpp" 

#define WWWROOT "/home/dyx/Oline_judge/HttpServer/wwwroot"
int main(int argc,char *argv[])
{

    if(argc!= 2){
        std::cout << "Usage: " << argv[0] << " port" << std::endl;
        return 1;
    }
    int port = atoi(argv[1]);
    HttpServer ser(port,100);
    ser.SetBaseDir(WWWROOT);
    ser.SetThreadNum(4);

    ser.SetPOST("/compile_run",[](const HttpRequest &req, HttpResponse *resp){
        // 用户请求的服务正文是我们想要的json string
        std::string in_json_str = req._body;
        std::string out_json_str;
        CompileToRun::Start(in_json_str,&out_json_str);
        resp->SetContent(out_json_str,"application/json;charset=UTF-8");
    });
    ser.Start();
    return 0;
}

